package info.webest.reminder.contacts;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.ContactsContract;

public class Contact {

	private String id;
	private int contact_id;
	private String photo_id;
	private String name;
	private int event_type;
	private Date event_date;
	private boolean event_year;
	private String age;
	private int interval;
	private int sort_index;

	public static void Show(Context context, int contact_id) {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		// Uri.Builder uriBuilder =
		// ContactsContract.Contacts.CONTENT_LOOKUP_URI.buildUpon();
		// uriBuilder.appendPath("/").appendPath(String.valueOf(contact_id));
		// intent.setData(uriBuilder.build());

		Uri uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI,
				String.valueOf(contact_id));
		intent.setData(uri);
		context.startActivity(intent);
	}

	public static void Call(Context context, String phoneNo) {
		String phoneNumber = "tel:" + phoneNo;
		Intent intent = new Intent(Intent.ACTION_CALL, Uri
				.parse(phoneNumber));
		context.startActivity(intent);		
	}
	
	// id
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	// contactId
	public int getContactId() {
		return contact_id;
	}

	public void setContactId(int contact_id) {
		this.contact_id = contact_id;
	}

	// photoId
	public String getPhotoId() {
		return photo_id;
	}

	public void setPhotoId(String photo_id) {
		this.photo_id = photo_id;
	}

	// Name
	public String getName() {
		return name;
		// return name + " (" + id + ")";
	}

	public void setName(String name) {
		this.name = name;
	}

	// EventType
	public int getEventType() {
		return event_type;
	}

	public void setEventType(int event_type) {
		this.event_type = event_type;
	}

	// EventDate (BIRTHDAY, )
	public Date getEventDate() {
		return event_date;
	}

	public void setEventDate(Date event_date) {
		this.event_date = event_date;
	}
	
	public void setDateWithYear(boolean dateWithYear) {
		this.event_year = dateWithYear;
	}	
	
	public boolean  getDateWithYear() {
		return this.event_year;
	}	

	public String getEventFormattedDate(String format) {
		SimpleDateFormat indexFormat = new SimpleDateFormat(format, Locale.getDefault());	
		return String.valueOf(indexFormat.format(getEventDate()));
	}
	
	// Age
	public String getAge() {
		return age;
	}

	public void setAge(String age) {
		this.age = age;
	}
	
	// turn in days
	public int getInterval() {
		return interval;
	}
	
	public void setInterval(int interval) {		
		this.interval = interval;
	}	
	

	// sortIndex
	public int getSortIndex() {
		return sort_index;
	}

	public void setSortIndex(int sort_index) {
		this.sort_index = sort_index;
	}
}
